package com.hitqz.robot.driver.zmq.protocol.handler;

import com.example.tutorial.AddressBookProtos;
import com.hitqz.robot.driver.util.WheelCacheUtil;
import com.hitqz.robot.driver.util.WheelToolkit;
import lombok.extern.slf4j.Slf4j;
import navconnector.NavconnectorBase;
import org.springframework.stereotype.Component;

/**
 * String数据类型处理类
 *
 * @author wengyx
 * @date 2021-10-29 08:47
 **/
@Slf4j
@Component
public class StringHandler implements HandlerZMQService {


    @Override
    public void handlerMsg(String robotSn, byte[] data) throws Exception {
        AddressBookProtos.String string = AddressBookProtos.String.parseFrom(data);
        String type = string.getDescriptorForType().getName();
        int ackId = string.getHeader().getAck();
        int objId = string.getHeader().getObj();
        String stringData = string.getData();
        //返回当前地图名称
        if (objId == AddressBookProtos.String.OBJ_ID.GET_CUR_MAP_NAME_REP_VALUE) {
            WheelCacheUtil.put(WheelCacheUtil.KEY_CURR_MAP_NAME,stringData);
        }
        //释放锁
        WheelToolkit.release(ackId,type, objId, true);

    }

}
